package CreativePattern.FactoryPattern;

import CreativePattern.FactoryPattern.Factory.abstractFactory.*;
//简单工厂方法模式-抽象工厂模式
public class TestFactory {

    public static void main(String[] args) {

//简单工厂方法模式
//        ICar sport= CarFactory.getCar("SPORT");
//        if (sport!=null){
//            sport.getCar();
//        }
//        ICar jeepCar=CarFactory.getCar("JeepCar");
//        if (jeepCar!=null){
//            jeepCar.getCar();
//        }
//        ICar hatchbackCar=CarFactory.getCar("HatchbackCar");
//        if (hatchbackCar!=null){
//            hatchbackCar.getCar();
//        }

        //抽象工厂模式
        AbstractFactory hatchbackFactory = new HatchbackCarFactory();
        AbstractCar hatchbackCar = hatchbackFactory.createCar();
        System.out.println("恭喜你获得了一俩超酷的"+hatchbackCar.getColor()+" "+hatchbackCar.getType()+"车");

        // Create Jeep car using JeepCarFactory
        AbstractFactory jeepFactory = new JeepCarFactory();
        AbstractCar jeepCar = jeepFactory.createCar();
        System.out.println("恭喜你获得了一俩凶猛的"+jeepCar.getColor()+" "+jeepCar.getType()+"车");

        // Create Sport car using SportCarFactory
        AbstractFactory sportFactory = new SportCarFactory();
        AbstractCar sportCar = sportFactory.createCar();
        System.out.println("恭喜你获得了一俩拉风的"+sportCar.getColor()+" "+sportCar.getType()+"车");

    }
}

